// pages/mine/mine.js

var WxParse = require("../../wxParse/wxParse.js");
var api = require("../../api.js"),
  e = require("../../utils/util.js"),
  r = "",
  app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    windowWidth: 0, //页面视图宽度
    windowHeight: 0, //视图高度
    userList: [],
    my_customers: [],
    /** 我邀请的客户列表 */
  },
  onLoad: function(options) {
    r = this;
    wx.getSystemInfo({
      success: function(res) {
        console.log(res)
        var windowHeight = res.windowHeight;
        //两列，每列的图片宽度
        var height = (windowHeight - 260);
        r.setData({
          windowHeight: height,
        }, function() {
          r.initData(); //初始化数据
        });
      },
    })
  },
  onShow: function() {
    // r.initData();
  },
  /** 初始化数据 */
  initData: function() {
    wx.showLoading({ title: '加载中...', })
    var t = new Object();
    t.openId = getApp().globalData.open_id;
    wx.request({
      url: api.mine.copartnerManager,
      data: t,
      success: function(res) {
        if (res.statusCode == 200 && res.data.code == 200) {
          var n = res.data.data;
          r.setData({
            buissbessData: res.data.data
          }, function() {
            wx.hideLoading()
          })
        }
      }
    });
    /** 我邀请的客户列表 */
    var c = new Object()
    c.open_id = getApp().globalData.open_id;
    wx.request({
      url: api.mine.my_invite_cunstomers,
      data: c,
      success: function (res) {
        if (res.statusCode == 200 && res.data.code == 200) {
          console.log(res.data.data)
          r.setData({
            my_customers: res.data.data
          }, function () {
            wx.hideLoading()
          })
        }
      }
    });


    wx.request({

      url: api.mine.subordinateCopartner,
      data: t,
      success: function(res) {
        if (res.statusCode == 200 && res.data.code == 200) {
          if (res.data.code == 200) {
            var n = res.data.data;
            r.setData({
              userList: res.data.data
            })
          } else {
            r.setData({
              userList: []
            })
          }

        }
      }
    })

  },

  moreuser: function() {
    wx.navigateTo({
      url: '../oneuser/oneuser'
    })
  },
  nextParner: function() {
    wx.navigateTo({
      url: '../parner/parner?type=1'
    })
  }
});